package com.shangyueshang.utils;

import com.github.pagehelper.PageInfo;
import com.shangyueshang.response.PageResult;

/**
 * @author: JokeyZheng
 * @email: zhengjingfeng@ruqimobility.com
 * @created: 2022/1/5 17:07
 * @version: v1.0.0
 */
public abstract class MyPageHelper {

    /**
     * 分页信息统一封装
     *
     * @param pageInfo
     * @return
     */
    public static <T> PageResult<T> getPageResult(PageInfo<T> pageInfo) {
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setPageNum(pageInfo.getPageNum());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setTotalSize(pageInfo.getTotal());
        pageResult.setTotalPages(pageInfo.getPages());
        pageResult.setContent(pageInfo.getList());
        return pageResult;
    }
}
